<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算属性</title>
</head>

<body>
    <div id="app">
        <label for="">你想要做什么：</label>
        <input type="text" v-model="thing">
        <button @click="add">增加</button>
        <ul>
            <li v-for="(todo,index) in todos" :key="todo+index">
                {{todo}}
                <button @click="remove(index)">删除</button>
            </li>
        </ul>
        
    </div>
    <script src="./js/vue.js"></script>
    <script src="./js/jquery.js"></script>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                thing:'',
                todos:['吃饭','睡觉']
            },
            methods:{
                add(){
                    if(this.thing){
                        this.todos.push(this.thing)
                    }
                },
                remove(index){
                    this.todos.splice(index,1)
                }
                // remove:function(index){
                //     this.todos.splice(index,1)
                // }
                // remove:(index) =>{
                //     this.todos.splice(index,1)
                // }
            },
            computed:{

            },
            watch:{

            }
           
        })
    </script>

</body>

</html>